import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue';
import SetupView from '../views/SetupView.vue';
import HoldView from '../views/HoldSetup.vue';
import IndexView from '../views/IndexView.vue';
import BtyIndex from '../views/BtyIndex.vue';
import Product from '../views/Product.vue';
import Category from '../views/Category.vue';
import Detail from '../views/Detail.vue';
import Technology from '../views/Technology.vue';
import Material from '../views/Material.vue';
import Promotion from '../views/Promotion.vue';
import About from '../views/About.vue';
import Shop from '../views/Shop.vue';
import Search from '../views/Search.vue';


const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/home',
      name: 'home',
      component: Home,
      redirect: 'btyindex',
      children: [
        {
          path: '/btyindex',
          name: 'btyindex',
          component: BtyIndex
        },
        {
          path: '/product',
          name: 'product',
          component: Product,
        },
        {
          path: '/category',
          name: 'category',
          component: Category
        },
        {
          path: '/detail',
          name: 'detail',
          component: Detail
        },
        {
          path: '/technology',
          name: 'technology',
          component: Technology
        },
        {
          path: '/material',
          name: 'material',
          component: Material
        },
        {
          path: '/promotion',
          name: 'promotion',
          component: Promotion
        },
        {
          path: '/about',
          name: 'about',
          component: About
        },
        {
          path: '/shop',
          name: 'shop',
          component: Shop
        },
        {
          path: '/search',
          name: 'search',
          component: Search
        },
        {
          path: '/news',
          name: 'news',
          component: () => import("../views/NewsDetail.vue")
        },
        {
          path: '/promotion_detail',
          name: 'promotion_detail',
          component: () => import("../views/PromotionDetail.vue")
        },
        {
          path: '/question',
          name: 'question',
          component: () => import("../views/Question.vue")
        },
        {
          path: '/car',
          name: 'car',
          component: () => import("../views/Car.vue")
        },
        {
          path: '/shopCenter',
          name: 'shopCenter',
          component: () => import("../views/ShopCenter.vue")
        },
        {
          path: '/login',
          name: 'login',
          component: ()=> import('../views/Login.vue')
        },
        {
          path: '/register',
          component: ()=>import('../views/Register.vue')
        },
        {
          path: '/user',
          component: ()=>import('../views/UserInfo.vue')
        },
      ]  
    },
    {
      path: '/admin',
      component: () => import("../views/admin/Index.vue"),
      redirect: 'category_first',
      children: [
        {
          path: "/admin/company",
          component: ()=>import("../views/admin/Company.vue")
        },
        {
          path: "/admin/order",
          component: ()=>import("../views/admin/Order.vue")
        },
        {
          path: "/admin/category_first",
          component: ()=>import("../views/admin/FirstCategory.vue")
        },
        {
          path: "/admin/category_second",
          component: ()=>import("../views/admin/SecondCategory.vue")
        },
        {
          path: "/admin/product",
          component: ()=>import("../views/admin/Product.vue")
        },
        {
          path: '/admin/add_product',
          component: ()=>import("../views/admin/AddProduct.vue")
        },
        {
          path: '/admin/update_product',
          component: ()=>import("../views/admin/UpdateProduct.vue")
        },
        {
          path: '/admin/promotional',
          component: ()=>import("../views/admin/Promotional.vue")
        },
        {
          path: '/admin/add_promotional',
          component: ()=>import("../views/admin/AddPromotional.vue")
        },
        {
          path: '/admin/update_promotional',
          component: ()=>import("../views/admin/UpdatePromotional.vue")
        },
        {
          path: '/admin/news',
          component: ()=>import("../views/admin/News.vue")
        },
        {
          path: '/admin/add_news',
          component: ()=>import("../views/admin/AddNews.vue")
        },
        {
          path: '/admin/update_news',
          component: ()=>import("../views/admin/UpdateNews.vue")
        },
        {
          path: '/admin/technology',
          component: ()=>import("../views/admin/Technology.vue")
        },
        {
          path: '/admin/add_technology',
          component: ()=>import("../views/admin/AddTechnology.vue")
        },
        {
          path: '/admin/update_technology',
          component: ()=>import("../views/admin/UpdateTechnology.vue")
        },
        {
          path: '/admin/lunbo',
          component: ()=>import("../views/admin/LunBo.vue")
        },
        {
          path: '/admin/sulunbo',
          component: ()=>import("../views/admin/SuLunBo.vue")
        },
        {
          path: '/admin/orderCenter',
          component: ()=>import("../views/admin/OrderCenter.vue")
        }
      ]
    },
    {
      path: '/en/home',
      name: 'enhome',
      component: ()=>import('../views/english/Home.vue'),
      redirect: '/en/btyindex',
      children: [
        {
          path: '/en/btyindex',
          name: 'enbtyindex',
          component: ()=>import('../views/english/BtyIndex.vue')
        },
        {
          path: '/en/product',
          name: 'enproduct',
          component: ()=>import('../views/english/Product.vue') ,
        },
        {
          path: '/en/category',
          name: 'encategory',
          component: ()=>import('../views/english/Category.vue')
        },
        {
          path: '/en/detail',
          name: 'endetail',
          component: ()=>import('../views/english/Detail.vue')
        },
        {
          path: '/en/technology',
          name: 'entechnology',
          component: ()=>import('../views/english/Technology.vue')
        },
        {
          path: '/en/material',
          name: 'enmaterial',
          component: ()=>import('../views/english/Material.vue')
        },
        {
          path: '/en/promotion',
          name: 'enpromotion',
          component: ()=>import('../views/english/Promotion.vue')
        },
        {
          path: '/en/about',
          name: 'enabout',
          component: ()=>import('../views/english/About.vue')
        },
        {
          path: '/en/shop',
          name: 'enshop',
          component: ()=>import('../views/english/Shop.vue')
        },
        {
          path: '/en/search',
          name: 'ensearch',
          component: ()=>import('../views/english/Search.vue')
        },
        {
          path: '/en/news',
          name: 'ennews',
          component: () => import("../views/english/NewsDetail.vue")
        },
        {
          path: '/en/promotion_detail',
          name: 'enpromotion_detail',
          component: () => import("../views/english/PromotionDetail.vue")
        },
        {
          path: '/en/question',
          name: 'enquestion',
          component: () => import("../views/english/Question.vue")
        },
        {
          path: '/en/car',
          name: 'encar',
          component: () => import("../views/english/Car.vue")
        },
        {
          path: '/en/shopCenter',
          name: 'enshopCenter',
          component: () => import("../views/english/ShopCenter.vue")
        },
        {
          path: '/en/login',
          name: 'enlogin',
          component: ()=> import('../views/english/Login.vue')
        },
        {
          path: '/en/register',
          component: ()=>import('../views/english/Register.vue')
        },
        {
          path: '/en/user',
          component: ()=>import('../views/english/UserInfo.vue')
        },
      ]  
    },


    {
      path: "/",
      name: "mhome",
      component: ()=>import("@/views/mobile/Home.vue"),
    },
    {
      path: "/m/product",
      name: "mproduct",
      component: ()=>import("@/views/mobile/Product.vue")
    },
    {
      path: '/m/productList',
      name: 'mproductList',
      component: ()=>import("@/views/mobile/ProductList.vue")
    },
    {
      path: '/m/technology',
      name: 'mtechnology',
      component: ()=>import('@/views/mobile/Technology.vue')
    },
    {
      path: '/m/question',
      name: 'mquestion',
      component: ()=>import('@/views/mobile/Company.vue')
    },
    {
      path: '/m/promotion',
      name: 'mpromotion',
      component: ()=>import('@/views/mobile/Promotion.vue')
    },
    {
      path: '/m/shopping',
      name: 'mshopping',
      component: ()=>import('@/views/mobile/Shopping.vue')
    },
    {
      path: '/m/user',
      name: 'muser',
      component: ()=>import('@/views/mobile/User.vue')
    },
    {
      path: '/m/productDetail',
      name: 'mproductDetail',
      component: ()=>import('@/views/mobile/ProductDetail.vue')
    },
    {
      path: '/m/login',
      name: 'nlogin',
      component: ()=>import('@/views/mobile/Login.vue')
    },
    {
      path: '/m/order',
      name: 'morder',
      component: ()=> import('@/views/mobile/Order.vue')
    },
    {
      path: '/m/information',
      name: 'minformation',
      component: ()=>import('@/views/mobile/Information.vue')
    },
    {
      path: '/m/search',
      name: 'msearch',
      component: ()=>import('@/views/mobile/Search.vue')
    },
    {
      path: '/m/register',
      name: 'mregister',
      component: ()=> import('@/views/mobile/Register.vue')
    },
    {
      path: '/m/company',
      name: 'mcompany',
      component: ()=>import('@/views/mobile/Company.vue')
    },
    {
      path: '/m/news',
      name: 'nnews',
      component: ()=>import('@/views/mobile/News.vue')
    },
    {
      path: '/test',
      name: 'test',
      component: ()=>import('@/views/Test.vue')
    }

  ],
  scrollBehavior(to, from, savedPosition) {
    // 确保每次路由变化时滚动到顶部
    return { top: 0 };
  },
})

export default router
